
export default {
    isToken(){
        if(uni.getStorageSync('user_token')!=null&&uni.getStorageSync('user_token')!=''&&uni.getStorageSync('user_token')!='undefined'){
            return true;
        }else{
            return false;
        }
    },
    setUserToken(token,tokenHead){
		uni.setStorageSync('user_token', token);
		uni.setStorageSync('user_tokenHead', tokenHead);
    },
    delUserToken(){
		 uni.removeStorageSync('user_token');
		 uni.removeStorageSync('user_tokenHead');
    },
    getUserToken(){
        return uni.getStorageSync('user_tokenHead')+uni.getStorageSync('user_token')
		
    },
	login(){
		if(!this.isToken()){
			uni.navigateTo({
				url: "/pages/login/login"
			});
		}
	},
	setSearchRecords(key){
		if(this.getSearchRecords()!=null&&this.getSearchRecords()!=''&&this.getSearchRecords()!='undefined'){
			let arr=this.getSearchRecords();
			let index=0;
			arr.forEach(e=>{
				if(e==key){
					arr.splice(index, 1); 
				}
				index++;
			})
			arr.unshift(key)
			uni.removeStorageSync('SearchRecords');
			uni.setStorageSync('SearchRecords', arr);
		}else{
			uni.setStorageSync('SearchRecords', [key]	);
			
		}
	},
	getSearchRecords(){
		return uni.getStorageSync('SearchRecords');
	},
	delSearchRecords(){
		uni.removeStorageSync('SearchRecords');
	},
}